//
//  MainViewController.swift
//  weibo
//
//  Created by hm on 2020/4/18.
//  Copyright © 2020 hm. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    private lazy var composeBtn: UIButton = UIButton(imageName: "tabbar_compose_icon_add", bgImageName: "tabbar_compose_button")
    
    // MARK:- 系统回调函数
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupComposeBtn()
        
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }
    
}

// MARK:- 设置UI
extension MainViewController {
    /// 设置发布按钮
    private func setupComposeBtn() {
        tabBar.addSubview(composeBtn)
        //设置位置:底部导航栏中心
        composeBtn.center = CGPoint(x: tabBar.center.x, y: tabBar.bounds.height * 0.5)
        //添加点击事件
        composeBtn.addTarget(self, action: #selector(self.composeBtnClick), for: .touchUpInside)
    }
    
}

// MARK:- 事件监听
extension MainViewController {
    //注意：事件方法要加@obj前缀
    //@objc作用：加入类的函数列表
    @objc private func composeBtnClick(){
        print("click")
    }
}
